<template>
	<view>
		<view class="status" :style="[{height:statusBar+ 'px'}]" ></view>
		<view class="common-header" :class="[bgShow?'bgColor':'']" :style="[{top:statusBar+ 'px'}]">
		  <view class="back-box" @click="back('normal')" v-if="is_share=='false'">
				<image src="/static/images/back.png" class="back" mode="" ></image>
			</view>
			<view class="back-box" @click="back('share')" v-if="is_share=='true'">
				<image src="/static/images/home.png" class="back" mode=""></image>
			</view>
		</view>
	</view>
  
</template>

<script>
	import store from "store"
	import {mapGetters,mapMutations,mapActions} from 'vuex'
	export default {
		name: "ProductHeaderCom",
		store,
		computed:{
			...mapGetters([
				'user',
				'statusBar'
			])
		},
		props: {
			bgShow:{
				type:Boolean,
				default:false
			},
			is_share:{
				type:String,
				default:'false'
			},
			invite_code:{
				default:null
			},
			isFromHome:{
				default:false
			}
		},
		methods: {
		 back(type){
			 if(type=='normal'){
				 if(this.isFromHome){
					uni.switchTab({
						 url:'/pages/index/index',
						 success: (res) => {
						 }
					})
				 }else{
					uni.setStorage({ 
						 key:"newsTop",
						 data:0
					})
					var pages= getCurrentPages()
					var prevPage = pages[pages.length-2]
					if(prevPage.__page__.fullPath=='/pages/activity/activity'){
						prevPage.$vm.backEvent()
					}
					
					 uni.navigateBack({});
				 }
			 }else{
				 uni.reLaunch({
					url: '/pages/index/index'
				 })
			 }
		 } 
		}
	}
</script>

<style lang="scss" scoped>
	.status {
		width: 100%;
		position: fixed;
		top: 0;
		z-index: 99;
		background: rgba(0,0,0,0);
	}
	.common-header{
		width: 750rpx;
		height: 88rpx;
		background: rgba(0,0,0,0);
		position: fixed;
		left:0;
		top: 0;
		z-index:99;
		display: flex;
		align-items: center;
	}
	.bgColor{
		background: rgba(0,0,0,.2);
	}
	.back-box{
		width: 60rpx;
		height: 60rpx;
		background: rgba(255,255,255,.5);
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 20rpx;
	}
	.back{
		display: block;
		width: 48rpx;
		height: 48rpx;
		
	}

</style>

